package com.yuxin.tongyi.lsll.sub;

import java.io.File;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

/**
 * @author daijinge
 * 为了控制启动安装apk的Activity后消除Notification
 */

public class InstallPackageActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Intent i = getIntent();
		//获取传来的数据
		String savePath = i.getStringExtra("savePath");
		String saveFileName = i.getStringExtra("saveFileName");
		File apkfile = new File(savePath+saveFileName);
		Uri uri = Uri.fromFile(apkfile);
		//设置安装文件的Intent
        Intent installIntent = new Intent(Intent.ACTION_VIEW);
        installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
        startActivity(installIntent);
        //获取Notification的管理器类
        NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        //清除Notification
        nm.cancelAll();
        //结束该activity返回安装之前的主界面
        this.finish();
	}	
}
